

/*
 * JeremyDBConnectObj.java
 *
 * Created on December 2, 2006, 11:46 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package com.asaga.tools;

import java.io.*;
import java.net.*;
import java.sql.*;
import java.util.*;

/**
 *
 * @author jeremys
 */
public class JeremyDBConnectObj {
    private Connection conn = null;
    private String worky;
    
    /** Creates a new instance of JeremyDBConnectObj */
    public JeremyDBConnectObj() {
        try{
            Class.forName("org.gjt.mm.mysql.Driver");
            String dbURL = "jdbc:mysql://blackbear.ecology.uga.edu:3306/autismdb";
            String username = ""; // you need to insert the correct username
            String password = ""; // you need to insert the correct password
            conn = DriverManager.getConnection(dbURL, username, password);
            this.worky = "Your object connected to db!";
        }
        catch(ClassNotFoundException e){
            this.worky = "Database driver not found." + e.getMessage();
        }
        catch(SQLException e ){
            this.worky = "can't load db" + e.getMessage();
        }
    }
   
    public Connection getConnection(){
        return this.conn;
    }
    
    public void close(){
        try {
            this.conn.close();
        } catch (SQLException ex) {
            ex.printStackTrace();
            worky = ex.toString();
        }
    }
    
    public String toString(){
        return this.worky;
    }
}
